package com.lmk.qs.jdbc;

import com.lmk.qs.domain.Emp;
import com.lmk.qs.utils.DruidUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;
import java.util.Map;

public class work01 {
    public static void main(String[] args) {
        JdbcTemplate jp = new JdbcTemplate(DruidUtil.getDataSource());
        String update = "update emp set salary=? where id=?";
        jp.update(update, 5000, 1);

        String insert = "insert into emp values(?,?,?,?,?,?)";
        String delete = "delete from  emp where id=?";
        String sql2 = "select * from emp where id=?";
        Map<String, Object> stringObjectMap = jp.queryForMap(sql2, 2);
        System.out.println(stringObjectMap);
        String sel1 = "select * from emp ";
        List<Map<String, Object>> maps1 = jp.queryForList(sel1);
        System.out.println(maps1);

        List<Emp> query = jp.query(sel1, new BeanPropertyRowMapper<Emp>(Emp.class));
        System.out.println(query);


    }
}
